package search;

import java.util.Scanner;
public class Search {
	public static int search(String str3,String str4){
		 int n=0,a;
		 for(a=0;a<str3.length();a++)
		 {
			 a=str3.indexOf(str4,a);
			 if(a>=0) {
				 n++;
			 }
			 else {
				 break;
			 }
		 }
		 return n;
	}
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		System.out.println("请输入一段字符串：");
		String str1=input.nextLine();
		System.out.println("请输入要查找的字符串：");
		String str2=input.nextLine();
		int m=search(str1, str2);
		System.out.println(str2+"在"+str1+"中"+"出现了"+m+"次");
	}
}
